/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interface;

import Negocio.CadastroEvent;
import Negocio.CadastroListener;
import Negocio.Lance;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractListModel;

/**
 *
 * @author v3550
 */
public class ListModelLance extends AbstractListModel<Lance> implements CadastroListener {
   private List<Lance> texto = new ArrayList<Lance>();
    
    public ListModelLance(){
        super();
    }
    
    public ListModelLance(List<Lance> dados){
        texto.addAll(dados);
    }
    
    @Override
    public int getSize() {
        return texto.size();
    }

    @Override
    public Lance getElementAt(int index) {
        return texto.get(index);
    }
    
    public void add(Lance s) {
        texto.add(s);
        fireIntervalAdded(this, texto.size(), texto.size());
    }

    @Override
    public void elementoAdicionado(CadastroEvent evt) {
        add((Lance) evt.getObjetoEvento());
    }  
}
